package com.wao.cms.domain;

import com.wao.base.domain.BaseMultitenantAuditingEntity;
import com.wao.base.hibernate.convert.StringSetConverter;
import io.swagger.annotations.ApiModel;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.time.ZonedDateTime;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

/**
 * Website entity.
 *
 * @author Arthur.
 */
@ApiModel(description = "Website entity. @author Arthur.")
@Entity
@Table(name = "cms_website")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Website extends BaseMultitenantAuditingEntity {

    private static final long serialVersionUID = 1L;

    @Column(name = "name")
    private String name;

    @Column(name = "image")
    private String image;

    @Column(name = "domain")
    private String domain;

    @Column(name = "copyright")
    private String copyright;

    @Column(name = "favicon")
    private String favicon;

    @Column(name = "expiration_time")
    private ZonedDateTime expirationTime;

    @Size(max = 8)
    @Column(name = "default_lang_key", length = 8)
    private String defaultLangKey;

    @Column(name = "lang_keys")
    @Convert(converter = StringSetConverter.class)
    private Set<String> langKeys = new LinkedHashSet<String>(0);

    @Column(name = "keywords")
    private String keywords;

    @Column(name = "description")
    private String description;

    @NotNull
    @Column(name = "enabled", nullable = false)
    private Boolean enabled;

    public String getName() {
        return name;
    }

    public Website name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public Website image(String image) {
        this.image = image;
        return this;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public String getDomain() {
        return domain;
    }

    public Website domain(String domain) {
        this.domain = domain;
        return this;
    }

    public void setDomain(String domain) {
        this.domain = domain;
    }

    public String getCopyright() {
        return copyright;
    }

    public Website copyright(String copyright) {
        this.copyright = copyright;
        return this;
    }

    public void setCopyright(String copyright) {
        this.copyright = copyright;
    }

    public String getFavicon() {
        return favicon;
    }

    public Website favicon(String favicon) {
        this.favicon = favicon;
        return this;
    }

    public void setFavicon(String favicon) {
        this.favicon = favicon;
    }

    public ZonedDateTime getExpirationTime() {
        return expirationTime;
    }

    public Website expirationTime(ZonedDateTime expirationTime) {
        this.expirationTime = expirationTime;
        return this;
    }

    public void setExpirationTime(ZonedDateTime expirationTime) {
        this.expirationTime = expirationTime;
    }

    public String getDefaultLangKey() {
        return defaultLangKey;
    }

    public Website defaultLangKey(String defaultLangKey) {
        this.defaultLangKey = defaultLangKey;
        return this;
    }

    public void setDefaultLangKey(String defaultLangKey) {
        this.defaultLangKey = defaultLangKey;
    }

    public Set<String> getLangKeys() {
        return langKeys;
    }

    public Website langKeys(Set<String> langKeys) {
        this.langKeys = langKeys;
        return this;
    }

    public void setLangKeys(Set<String> langKeys) {
        this.langKeys = langKeys;
    }

    public String getKeywords() {
        return keywords;
    }

    public Website keywords(String keywords) {
        this.keywords = keywords;
        return this;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getDescription() {
        return description;
    }

    public Website description(String description) {
        this.description = description;
        return this;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Boolean isEnabled() {
        return enabled;
    }

    public Website enabled(Boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Website website = (Website) o;
        if (website.getId() == null || getId() == null) {
            return false;
        }
        return Objects.equals(getId(), website.getId());
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(getId());
    }

    @Override
    public String toString() {
        return "Website{" +
            "id=" + getId() +
            ", name='" + getName() + "'" +
            ", image='" + getImage() + "'" +
            ", domain='" + getDomain() + "'" +
            ", copyright='" + getCopyright() + "'" +
            ", favicon='" + getFavicon() + "'" +
            ", expirationTime='" + getExpirationTime() + "'" +
            ", defaultLangKey='" + getDefaultLangKey() + "'" +
            ", langKeys='" + getLangKeys() + "'" +
            ", keywords='" + getKeywords() + "'" +
            ", description='" + getDescription() + "'" +
            ", enabled='" + isEnabled() + "'" +
            "}";
    }
}
